package com.imu.common.utils;

import java.util.regex.Pattern;

import com.qiniu.util.StringUtils;
import tk.mybatis.mapper.util.StringUtil;

public class PhoneUtil {
	
	private static Pattern pattern = Pattern.compile("^[1][3-8]\\d{9}$|^852([6|9])\\d{7}$|^886[0][9]\\d{8}$|^853[6]([8|6])\\d{5}$");

	private static Pattern xPattern = Pattern.compile("^1\\d{10}$|^852([6|9])\\d{7}$|^886[0][9]\\d{8}$|^853[6]([8|6])\\d{5}$");

	//国内手机号码
	private static Pattern cPattern = Pattern.compile("^((0086)|(86))?[1][0-9]\\d{9}$");

	//港澳台手机号码
	private static Pattern tPattern = Pattern.compile("^852([6|9])\\d{7}$|^886[0][9]\\d{8}$|^853[6]([8|6])\\d{5}$");


	public static boolean isPhone(String phone){
		if(StringUtils.isNullOrEmpty(phone)){
			return false;
		}
		if(!pattern.matcher(phone).matches()){
			return false;
		}
		return true;
	}

	public static boolean isXPhone(String phone){
		if(StringUtils.isNullOrEmpty(phone)){
			return false;
		}
		if(!xPattern.matcher(phone).matches()){
			return false;
		}
		return true;
	}

	/**
	 * 港澳台手机号码
	 * @param phone
	 * @return
	 */
	public static boolean isTwPhone(String phone){
		if(StringUtils.isNullOrEmpty(phone)){
			return false;
		}
		if(!tPattern.matcher(phone).matches()){
			return false;
		}
		return true;
	}

	/**
	 * 国内手机号码
	 * @param phone
	 * @return
	 */
	public static boolean isCPhone(String phone){
		if(StringUtils.isNullOrEmpty(phone)){
			return false;
		}
		if(!cPattern.matcher(phone).matches()){
			return false;
		}
		return true;
	}
	public static void main(String[] args){
		System.out.println(isXPhone("10000000000"));
	}
}
